<%
################################################################################
# NOTE: It is STRONGLY suggested that if you wish to customize the look and feel
# of your Helpy, that you create a custom theme instead.  This will allow
# you to override any views or styles you wish to, without compromising your
# ability to upgrade in the future
################################################################################
%>

<!-- standard post partial -->
<div id="post-<%= post.id %>" class="media post-container <%= "kind-#{post.kind}" %><%= post.topic.forum.allow_post_voting? ? "" : " disallow-post-voting" %><%= " inactive" unless post.active? %>">
	<div class="pull-left">
		<%= avatar_image(post.user, size=40) %>
	</div>
	<div class="media-body media-right">
		<span class="hidden-sm hidden-md hidden-lg"><%= last_active_time(post.created_at) %><br/></span>
		<span id="row-<%= post.id %>"  class="post-menu post-menu-<%= post.id %> btn-group">
			<%= post_message(post) %>
		</span>

		<span class="last-active posted-at less-important pull-right">
			<span class="hidden-xs">
				<%= last_active_time(post.created_at) %>
			</span>
		</span>

		<div id="post-body-<%= post.id %>" class="post-body less-important text-left text-content">
			<%= post.html_formatted_body %>
			<% if post.topic.forum.allow_post_voting == true %>
			<div id="post-vote-<%= post.id %>" class="btn btn-default">
				<% if post.kind == 'first' %>
				<%= link_to t(:upvote, count: post.topic.points), up_vote_path(post.topic.id), method: :post, remote: true, class: 'topic-vote', data: {voted: post.topic.to_param}, id: "upvote_#{post.topic.id}" %>
				<% else %>
				<%= link_to t(:upvote, count: post.points), post_vote_path(post.id), method: :post, remote: true, class: 'post-vote', data: {voted: post.id}, id: "upvote_#{post.id}"  %>
				<% end %>
			</div>
			<% end %>
			<div class="public-post-options pull-right less-important">
				<%= render :partial => 'posts/flag' if post.topic.public? %>
			</div>
      <%= render partial: 'posts/thumbnail', locals: { :model_name => post } %>
      <%= render partial: 'posts/attachment', locals: { :model_name => post } %>
    </div>

		<% if user_signed_in? && post.kind == 'first' && post.topic.forum.allow_post_voting == true %>
			<div class="add-form inline-reply">
			<h4><%= t(:reply) %></h4>
			<%= bootstrap_form_for :post, :url => topic_posts_path(@topic) do |f| -%>
			  <%= f.text_area :body, :rows => 4, :cols => 160, label: 'Type your response:' -%></p>
			  <%= f.hidden_field 'kind', value: 'reply' %>
				<div class="add-screenshots">
				<%= attachinary_file_field_tag 'post[screenshots]', @topic.posts.new, :screenshots if cloudinary_enabled? %>
				</div>
				<% unless cloudinary_enabled? %>
					<%= f.file_field :attachments, multiple: true %>
					<ul class="list-inline" id="attachments">
						<%= render partial: 'posts/attachment', locals: { :model_name => post } %>
					</ul>
				<% end %>
				<%= hidden_field_tag :client_id %>
				<%= f.submit t(:submit_reply), class: 'btn btn-warning' -%>
			<% end -%>
			</div>
		<% end -%>

	</div>
</div>

<div id="flag-modal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title"><%= t(:flag_post_for_review, default: "Flag For Review") %></h4>
      </div>

      <div class="modal-body row">
        <div class="col-md-12">
        <%= bootstrap_form_for :flag, :url => post_flags_path(post) do |f| -%>
          <%= f.text_area :reason, rows: 6, cols: 160, placeholder: t(:flag_post_placeholder), skip_label: true -%>
          <%= f.submit t(:flag, default: "Flag"), class: 'btn btn-warning' -%>
        <% end -%>
        </div>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
